package com.lx.mobileplayer.app

import android.app.Application
import android.content.Context
import android.os.Handler
import android.os.Looper
import com.lx.mobileplayer.utils.ResourcesUtil

/**
 * 类说明：Application
 * Created by liuxiong on 2019/4/25.
 */
class MyApplication : Application() {

    companion object {
        var appContext: Context?=null

        val uiHandler: Handler by lazy {
            Handler(Looper.getMainLooper())
        }

    }


    override fun onCreate() {
        super.onCreate()
        appContext= applicationContext

        ResourcesUtil.init(appContext)


        /** 申请权限被拒绝统一处理 */
       /* GPermisson.init(object : PermissionGlobalConfigCallback() {
            override fun shouldShowRational(permission: String, ration: Int) {
                *//** 用户拒绝了授予权限，并且没有勾选 don’t ask again*//*

                var message=when(ration){
                    Permissions.WRITE_EXTERNAL_STORAGE->"app需要访问媒体文件的权限，否则将影响功能"
                    else->"app需要刚才申请的权限，请同意申请"
                }

                AlertDialogUtil.showDialog(AppManager.getLastActivity(),
                    message=message,positiveButtonText = "确定",
                    positivewListener = DialogInterface.OnClickListener { dialog, which ->
                        dialog.dismiss()
                    })
            }

            override fun onPermissonReject(permission: String, reject: Int) {
                *//** 用户拒绝了授予权限，并且勾选 don’t ask again*//*

                var message=when(reject){
                    Permissions.WRITE_EXTERNAL_STORAGE->"app需要访问媒体文件的权限，否则将影响功能"
                    else->"app需要刚才申请的权限，请同意申请"
                }

                AlertDialogUtil.showDialog(AppManager.getLastActivity(),
                    message=message,positiveButtonText = "确定",
                    positivewListener = DialogInterface.OnClickListener { dialog, which ->
                        GPermisson.startSettingsActivity(AppManager.getLastActivity())
                        dialog.dismiss()
                    })
            }
        })*/
    }
}